package com.example.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.dto.OrderFromDto;
import com.example.dto.ProDto;
import com.example.service.OrderFromService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("orderFrom")
public class OrderFromController {
    @Autowired
    private OrderFromService service;
    @RequestMapping("add")
    public Object add(@RequestBody OrderFromDto dto) {
        dto.setAddTime(LocalDateTime.now());
        service.add(dto);
        return null;
    }

    @RequestMapping("select")
    public IPage<OrderFromDto> select(@RequestBody OrderFromDto dto) {
        IPage<OrderFromDto> page = service.select(dto);
        return page;
    }
    /*@RequestMapping("selectName")
    public List<Map<String,Object>> selectName() {
        List<Map<String,Object>>listmap = service.selectName();
//        System.out.println(listmap);
        return listmap;
    }*/
    @RequestMapping("update")
    public Object update(@RequestBody OrderFromDto dto) {
        service.update(dto);
        return null;
    }

    @RequestMapping("delete")
    public Object delete(@RequestBody OrderFromDto dto) {
        service.delete(dto);
        return null;
    }


}
